# Contributor: Alex Yam <alex@alexyam.com>
# Maintainer: Alex Yam <alex@alexyam.com>
pkgname=pari
pkgver=2.15.4
pkgrel=0
pkgdesc="computer algebra system designed for fast computations in number theory"
url="https://pari.math.u-bordeaux.fr/"
arch="all !x86 !armv7 !armhf" # x86/armv7/armhf failed test matsnf-sta and matsnf-dyn
license="GPL-2.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="gmp-dev readline-dev perl"
checkdepends="diffutils" # BusyBox diff: unrecognized option: c
subpackages="$pkgname-dev $pkgname-libs:_lib $pkgname-doc"
source="https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-$pkgver.tar.gz"

build() {
	export CFLAGS="$CFLAGS -O2 -flto=auto"
	export CPPFLAGS="$CPPFLAGS -O2 -flto=auto"
	./Configure \
		--prefix=/usr \
		--mt=pthread \
		--with-readline \
		--with-gmp \
		--graphic=svg
	make all
}

check() {
	make dobench
}

package() {
	make DESTDIR="$pkgdir" install
}

_lib() {
	# symlink is backwards so it doesn't move otherwise
	amove usr/lib/libpari*
}

doc() {
	default_doc

	amove usr/share/pari/doc \
		usr/share/pari/examples
}

sha512sums="
2b9f0c1fe7198406df8e6ceb3fcdc8bfb75f5c7ebfb963f023a1eebfff0bcc26e3b690941e188d6b9f8dfb6cddf4ce4c00f2cc320ebe47d42ae7596c774ed6cc  pari-2.15.4.tar.gz
"
